﻿using SqlSugar;
using System;
using System.Collections.Generic;

namespace QingZhouLinYe_Web.Models
{
    [SugarTable("SheBei")]
    public class SheBei
    {
        [SugarColumn(IsIdentity =true,IsPrimaryKey =true,ColumnDescription ="主键Id")]
        public int Id { get; set; }

        [SugarColumn(ColumnDescription ="防火单位Id")]
        public int FangHuoDanWeiId { get; set; }

        [SugarColumn(ColumnDescription = "设备类型Id")]
        public int LeiXingId { get; set; }

        [SugarColumn(ColumnDescription ="设备IMEI序列号")]
        public string IMEI { get; set; }

        [SugarColumn(ColumnDescription = "设备使用人", IsNullable = true)]
        public string ShiYongRen { get; set; }

        [SugarColumn(ColumnDescription = "联系方式", IsNullable = true)]
        public string LianXiFangShi { get; set; }


        [SugarColumn(ColumnDescription = "设备当前位置",IsNullable = true,ColumnDataType ="geometry", SqlParameterDbType = typeof(LocationConverter))]
        public Location Shape { get; set; }

        [SugarColumn(ColumnDescription = "设备最后位置时间", IsNullable = true)]
        public DateTime LastOnLine { get; set; }


        [SugarColumn(IsIgnore = true)]
        [Navigate(NavigateType.ManyToOne,nameof(FangHuoDanWeiId))]  //配置多对一关系，定义多个设备属于一个防火单位
        public FangHuoDanWei FangHuoDanWei { get; set; }

        [SugarColumn(IsIgnore =true)]
        [Navigate(NavigateType.ManyToOne,nameof(LeiXingId))]    //配置多对一关系，定义多个设备属于一个设备类型
        public SheBeiLeiXing SheBeiLeiXing { get; set; }

        [SugarColumn(IsIgnore = true)]    //CodeFist数据库时不映射字段
        [Navigate(NavigateType.OneToMany, nameof(HuoQing.FangHuoDanWeiId))]   //配置一对多关系，定义一个设备有多个火情
        public List<HuoQing> HuoQings { get; set; }
    }
}